About: "Contains a Tool for making graticules and measured grids on viewframes in a layout. (v3.1)"
CanUnloadScript: 141
UnloadScript: 142
InstallScript: 143
UninstallScript: 144
ExtVersion: 1
)
(Butn.2
Help: "Graticules and Grids//Use this to place a graticule around the selected viewframe"
Update: "GratGrids.LayoutGraticule Update"
Icon: 3
Click: "GratGrids.LayoutGraticule Show"
)
(AVIcon.3
Name: "Graticule/Grid"
Res: "Icons.Graticule/Grid"
)
(Choice.4
Help: "Use this to place a graticule around the selected viewframe"
HelpTopic: "Layout_Graticule_and_Grid"
Update: "GratGrids.LayoutGraticule Update"
Label: "Add Graticule or Grid"
Click: "GratGrids.LayoutGraticule Show"
Shortcut: "Keys.None"
)
(AVDLog.5
Name: "Grat Grids Layout Grids and Graticules"
X: 39
Y: 131
W: 564
H: 312
HelpTopic: "Layout_Graticule_and_Grid"
ConstrainedControlNames: 6
ConstrainedControlNames: 7
ConstrainedControlNames: 8
ConstrainedControlNames: 9
ConstrainedControlNames: 10
Constraints: 11
Constraints: 12
Constraints: 13
Constraints: 14
Constraints: 15
Server: 16
ControlPanel: 17
Title: "Graticule and Grid Wizard"
EscapeEnabled: 1
AlwaysOnTop: 1
HasTitleBar: 1
Closeable: 1
Close: "GratGrids.LayoutGraticule Close"
Open: "GratGrids.LayoutGraticule Open"
DefaultButton: 127
)
(AVStr.6
S: "Finish"
)
(AVStr.7
S: "Next"
)
(AVStr.8
S: "Back"
)
(AVStr.9
S: "Cancel"
)
(AVStr.10
S: "aLabelButton1"
)
(Numb.11
N: 85.00000000000000
)
(Numb.12
N: 85.00000000000000
)
(Numb.13
N: 85.00000000000000
)
(Numb.14
N: 85.00000000000000
)
(Numb.15
N: 85.00000000000000
)
(Nil.16
InternalName: "MapTool"
)
(CPanel.17
Child: 18
Child: 22
Child: 34
Child: 59
Child: 90
Child: 91
Child: 92
Child: 93
Child: 94
Child: 116
ResBox: 117
ResBox: 118
ResBox: 119
ResBox: 120
ResBox: 121
ResBox: 122
ResBox: 123
ResBox: 124
ResBox: 125
ResBox: 126
Listening: 1
)
(CPanel.18
InternalName: "BackPanel"
Child: 19
Constraints: 0x55
ResBox: 21
VisibleBorder: 1
Listening: 1
)
(AVIBox.19
InternalName: "WizImage"
Constraints: 0x55
Icon: 20
Listening: 1
)
(AVIcon.20
Name: "Check"
Res: "Icons.Check"
)
(RectD.21
Left: 8.00000000000000
Top: 264.00000000000000
Right: 174.00000000000000
Bottom: 8.00000000000000
)
(CPanel.22
InternalName: "OptionPanel"
Child: 23
Child: 25
Child: 26
Child: 27
Child: 28
Constraints: 0x55
ResBox: 29
ResBox: 30
ResBox: 31
ResBox: 32
ResBox: 33
VisibleBorder: 1
Listening: 1
)
(AVCBBox.23
InternalName: "viewFrames"
Help: "Choose a which viewframe you want to place a graticule or grid on"
NextControl: 24
ContentKind: 4
Constraints: 0x55
Listening: 1
Select: "GratGrids.LayoutGraticule Change View"
)
(Nil.24
InternalName: "MapTool"
)
(AVCBox.25
InternalName: "SelectGrid"
Help: "When you check this, the wizard will show options for measured grids"
Listening: 1
Label: "Create a measured grid"
Click: "GratGrids.LayoutGraticule Select Option"
Constraints: 0x55
)
(TextLabel.26
InternalName: "aTextLabel39"
Constraints: 0x55
Label: "Choose the view frame that you want \nto place a grid or graticule on:"
Listening: 1
)
(AVCBox.27
InternalName: "SelectGrat"
Help: "When you check this, the wizard will show options for graticules"
Listening: 1
Selected: 1
Label: "Create a graticule"
Click: "GratGrids.LayoutGraticule Select Option"
Constraints: 0x55
)
(TextLabel.28
InternalName: "aTextLabel12"
Constraints: 0x55
Label: "This wizard will help you place a graticule or a \nmeasured grid on a viewframe in your layout.\nAs you progress through the wizard, you can\nverify how the settings you've customized so\nfar look by clicking the Preview button."
SourceCode: "theLayout = av.GetActiveDoc\nif ( Not (theLayout.is(Layout))) then\n Msgbox.Info(\"Please make your layout active again.\",\"Oops\")\n return nil\nend\ntheGraphics = theLayout.GetGraphics\nMTD = av.FindDialog(\"Grat Grids Layout Grids and Graticules\")\nViewFrames = MTD.FindByName(\"viewFrames\")\n\n\ntheView = av.GetProject.FindDoc(ViewFrames.GetSelection)\nvfs = av.GetActiveDoc.GetGraphics.FindAllByClass(ViewFrame)\nvfl = {}\nHasPrjData = false\nthisPrj = theView.GetProjection\nif (thisPrj.IsNull) then\n for each t in theVi
ew.GetThemes\n te = t.ReturnExtent.AsPolygon\n br = Rect.MakeXY(-181,-90,181,90).AsPolygon\n if (br.Contains(te).Not) then\n MTD.FindByName(\"SelectGrat\").SetSelected(false)\n MTD.FindByName(\"SelectGrat\").SetEnabled(false)\n HasPrjData = true\n break\n end\n end\nend\n\nif ((HasPrjData.Not) and (MTD.FindByName(\"SelectGrat\").IsEnabled.Not)) then\n MTD.FindByName(\"SelectGrat\").SetSelected(true)\n MTD.FindByName(\"SelectGrat\").SetEnabled(true)\nend\n\nfor each vf in vfs\n tV = vf.GetFillObject.
GetName\n if (tV = theView.GetName) then\n theGraphic = vf\n end\nend\n\nMTD = av.FindDialog(\"Grat Grids Layout Grids and Graticules\")\n\nxyRect = theGraphic.GetMapDisplay.ReturnExtent\nxyOrigin = xyrect.ReturnOrigin\nxySize = xyrect.ReturnSize\nminLength = xySize.GetX Min xySize.GetY\nxyIntervals = {20000000,10000000,5000000,2000000,1000000,500000,200000,100000,50000,20000,10000,5000,2000,1000,500,200,100,50,20,10,5,2,1 }\nrawInterval = minLength / 4 ' 4 is the default number of lines\ntheInterval = xyInterva
ls.Get( xyIntervals.Count - 1 )\nfor each val in xyIntervals\n if (rawInterval >= val) then\n theInterval = val\n break\n end\nend\ntheInt = theInterval.SetFormat(\"d\")\nMTD.FindByName(\"GridInt\").SetText(theInt.AsString)"
)
(Script.130
Name: "GratGrids.LayoutGraticule Create"
SourceCode: "MTD = av.FindDialog(\"Grat Grids Layout Grids and Graticules\")\ntheLayout = av.GetActiveDoc\nif ( Not (theLayout.is(Layout))) then\n Msgbox.Info(\"Please make your layout active again.\",\"Oops\")\n return nil\nend\ntheGraphics = theLayout.GetGraphics\nif (Self.GetLabel = \"Finish\") then\n theGraphics.UnSelectAll\n tests = theGraphics.FindAllByName(\"Preview_GratGrid\")\n if (tests <> nil) then\n for each gsgx in tests\n gsgx.SetSelected(true)\n gsgx.SetName(\"Final\")\n end\n theGraphics.GroupSelected\n
t tell which graphical options are to be used. *\n'*******************************************************************\n\ndoXYGrid = false\ndoGridLines = false\ndoGraticule = false\ndoLatLongs = false \nif (SelGrat.IsSelected) then\n doGraticule = true\n if (GratAndLab.IsSelected) then\n doLatLongs = true \n end \nend\nif (SelGrid.IsSelected) then\n doXYGrid = true\n if (GridLines) then\n doGridLines = true\n end\nend\n\ntheView = av.GetProject.FindDoc(ViewFrames.GetSelection)\nvfs = av.GetActiveDoc.GetGraphics.Find
AllByClass(ViewFrame)\nvfl = {}\nIsProj = true\nfor each vf in vfs\n tV = vf.GetFillObject.GetName\n if (tV = theView.GetName) then\n theGraphic = vf\n end\nend\n\ntheView = theGraphic.GetFillObject\nthisPrj = theView.GetProjection\nif (thisPrj.IsNull) then\n isProj = false\nend\n\n' Extent of view frame in page units (inches)\ndOrigin = theGraphic.GetOrigin\ndSize = theGraphic.GetExtent\ndRect = Rect.Make( dOrigin, dSize )\n\n' Extent of view frame in map units to solve a feature in \n' ReturnExtents that gives erroniou
s results when extentpreserved \n' is set to true set extent preserved to false, get the extent, \n' and set it back to its original value.\ncurSetting = theGraphic.IsExtentPreserved \ntheGraphic.SetExtentPreserved(false)\nxyRect = theGraphic.GetMapDisplay.ReturnExtent \nxyOrigin = xyrect.ReturnOrigin \nxySize = xyrect.ReturnSize\ntheGraphic.SetExtentPreserved(curSetting) \n\n' This is how to translate a point from map coords to page coords\n'aPt = dOrigin + ( ((p - xyOrigin) / xySize) * dSize)\n\nxMin = xyOrigin.GetX\ny
Min = xyOrigin.GetY\nxMax = xMin + xySize.GetX\nyMax = yMin + xySize.GetY\n\nif ( doGraticule ) then\n point1= Point.Make(xMin,yMin)\n point2= Point.Make(xMax,yMin)\n point3= Point.Make(xMax,yMax)\n point4= Point.Make(xMin,yMax)\n point5= Point.Make((xMin+(xMax-xMin)/2),yMin)\n point6= Point.Make(xMax,(yMin+(yMax-yMin)/2))\n point7= Point.Make((xMin+(xMax-xMin)/2),yMax)\n point8= Point.Make(xMin,(yMin+(yMax-yMin)/2))\n if (IsProj) then\n a = thisPrj.UnProjectPt(point1)\n b = thisPrj.UnProjectPt(point2)\n
c = thisPrj.UnProjectPt(point3)\n d = thisPrj.UnProjectPt(point4)\n e = thisPrj.UnProjectPt(point5)\n f = thisPrj.UnProjectPt(point6)\n g = thisPrj.UnProjectPt(point7)\n h = thisPrj.UnProjectPt(point8)\n else\n a = true\n b = true\n c = true\n d = true\n e = true\n f = true\n g = true\n h = true\n end\n if (((d) and (h) and (a)) and (a <> false)) then\n minlon= (Point1.GetX)Min(Point4.GetX)Min(Point8.GetX)Max(-180)\n else\n minlon = -180\n end\n if (((a) and (b) and (e)) and (
a <> false)) then\n minlat= (Point1.GetY)Min(Point2.GetY)Min(Point5.GetY)Max(-90)\n else\n minlat = -90\n end\n if (((b) and (c) and (f)) and (b <> false)) then\n maxlon= (Point2.GetX)Max(Point3.GetX)Max(Point6.GetX)Min(180)\n else\n maxlon = 180\n end\n if (((c) and (d) and (g)) and (c <> false)) then\n maxlat= (Point3.GetY)Max(Point4.GetY)Max(Point7.GetY)Min(90)\n else\n maxlat = 90\n end\n lonInterval = longdeg + ( longmin / 60) + ( longsec / 3600)\n latInterval = degrees + ( Minutes / 60)
o = aPt.Clone - ((mygText.GetExtent.GetX/2)@(mygText.GetExtent.GetY + (Gt - 0.03)))\n elseif ( (aPt.GetY + 0.05) >= dRect.GetTop) then\n theGratLine = GraphicShape.Make( Line.Make( aPt+(0@0.05), aPt ) )\n o = aPt.Clone - ((mygText.GetExtent.GetX/2)@(-Gt))\n else\n continue\n end\n\n mygText.SetOrigin(o)\n addTheLab = true\n for each l in LabelsMade\n if (mygText.GetBounds.Intersects(l.GetBounds.Clone.InsetBy(0.03))) then\n
addTheLab = false\n end\n end\n if (addTheLab) then\n mygText.setobjecttag(\"mygText\")\n theGraphics.Addbatch(mygText) \n mygText.SetName(\"Preview_GratGrid\")\n theGratLine.SetSymbol( gratLine )\n theGraphics.AddBatch( theGratLine )\n theGratLine.SetName(\"Preview_GratGrid\")\n LabelsMade.Add(mygText)\n end\n end\n end ' of foreach in prjLine\n end ' of foreach in lonList\nend ' of if (doLatLongs)\n\nif ( doXYGrid ) the
n\n'** Draw metres graticule as lines, with coordinates all around vertical lines\n if (GridLines) then\n xoffset = (gratxe/2)@0\n yoffset = 0@(gratye/2)\n else\n xoffset = 0.0625@0\n yoffset = 0@0.0625\n end\n for each x in gratxs .. gratxe by gratdx\n if ( (x < xMin) or (x > xMax) ) then\n continue\n end\n for each y in gratys .. gratye by gratdy\n if ( (y < yMin) or (y > yMax) ) then\n continue\n end\n aPt = dOrigin + ( ((x@y - xyOrigin) / xySize) * dSize)\n aP
olyLine = PolyLine.Make( {\n { aPt-xoffset, aPt+xoffset, aPt, aPt-yoffset, aPt+yoffset } } )\n ggLine = aPolyLine.ReturnClipped( dRect )\n gLine = GraphicShape.Make( ggLine )\n theGraphics.Addbatch( gLine )\n gline.SetName(\"Preview_GratGrid\")\n gLine.SetSymbol(blackline)\n end\n end\n for each x in gratxs .. gratxe by gratdx\n if ( (x < xMin) or (x > xMax) ) then\n continue\n end\n ' put easting label at ymax\n aPt = dOrigin + ( ((Point.Make(x,yMax) - xyOrigin) /
\n gline.SetName(\"Preview_GratGrid\")\n gLine.SetSymbol( blackLine )\n mygText= GraphicText.Make(x.SetFormat(\"d\").AsString, aPt)\n mygText.setobjecttag(\"mygText\")\n theGraphics.Addbatch(mygText)\n mygText.SetName(\"Preview_GratGrid\")\n mygText.SetSymbol(xySymbol)\n mygText.SetDisplay(theLayout.GetDisplay)\n o = aPt - ( (mygText.GetExtent.GetX/2)@(mygText.GetExtent.GetY + 0.03))\n mygText.SetOrigin(o)\n end ' of for each x\n for each y in gratys .. gratye by gratdy\n if ( (y < yMin) or (
d\nend\ntheGraphics.EndBatch\n\n\ntheGraphics.UnSelectAll\nif (nil<>thegraphics.FindAllByName(\"GratGrid\")) then\n for each agraphic in thegraphics.FindAllByName(\"Preview_GratGrid\")\n agraphic.setselected(true)\n end\n thegraphics.groupselected\n theGraphics.getSelected.Get(0).SetName(\"Preview_GratGrid\")\nend\n\ntheGraphics.Invalidate\n\nFinishButton = MTD.FindByName(\"Finish\")\nFinishButton.SetHelp(\"Keep this preview and close the graticule and grid wizard\")\nFinishButton.SetLabel(\"Finish\")\nNextButton = MTD.FindByName(
\"Next\")\nNextButton.SetLabel(\"Remove\")\nNextButton.SetHelp(\"Remove this preview of the graticule or grid and continue working in the wizard\")\nNextButton.SetEnabled(true)\nBackButton = MTD.FindByName(\"Back\")\nBackButton.SetEnabled(false)\n\n"
if (LabOnly.IsSelected) then\n 'GratColor.SetEnabled(false)\n GratLineWt.SetEnabled(false)\nend"
)
(Script.134
Name: "GratGrids.LayoutGraticule Open"
SourceCode: "MTD = av.FindDialog(\"Grat Grids Layout Grids and Graticules\")\n\nCancelButton = MTD.FindByName(\"Cancel\")\nBackButton = MTD.FindByName(\"Back\")\nNextButton = MTD.FindByName(\"Next\")\nNextButton.SetLabel(\"Next >>\")\nNextButton.SetHelp(\"Shows the next panel of the graticule and grid wizard\")\nFinishButton = MTD.FindByName(\"Finish\")\nFinishButton.SetLabel(\"Preview\")\nFinishButton.SetHelp(\"Previews the graticule or grid using the current settings\")\nOptionPanel = MTD.FindByName(\"OptionPanel\")\nGratPanel = MTD.FindByName(\"Gra
.DeepClone)\nMapBorderStyle.GoFirst\nLabelBorderStyle.GoFirst\nMapBorderStyle.SetVisible(false)\nMapBorderStyle.SetVisible(true)\nLabelBorderStyle.SetVisible(false)\nLabelBorderStyle.SetVisible(true)\n\nLabelSizes = {\"10\"}\nfor each h in 6..24\n LabelSizes.Add(h.AsString)\nend\nGridLabelSize.DefineFromList(LabelSizes.DeepClone)\nGratLabelSize.DefineFromList(LabelSizes.DeepClone)\n\nGratLabFont.Select\nGridLabFont.Select\n\nMapBorderStyle.SetEnabled(true)\nMapBorderColor.SetEnabled(true)\nMapBorderOptions.SetEnabled((BorderAro
s = av.GetActiveDoc.GetGraphics.FindAllByClass(ViewFrame)\n vfl = {}\n vfx = {}\n IsProjData = false\n RThese = {}\n for each vv in 0..(vfs.Count - 1)\n if (vfs.Get(vv).GetFillObject = nil) then\n RThese.Insert(vv)\n else\n vfl.Add(vfs.Get(vv).GetFillObject.GetName)\n vfx.Add(vfs.Get(vv).GetFillObject)\n end\n end\n for each rr in RThese\n vfs.Remove(rr)\n end\n theView = vfs.Get(0).GetFillObject\n thisPrj = theView.GetProjection\n if (thisPrj.IsNull) then\n for each t in theView.GetTh
emes\n te = t.ReturnExtent.AsPolygon\n br = Rect.MakeXY(-181,-90,181,90).AsPolygon\n if (br.Contains(te).Not) then\n MTD.FindByName(\"SelectGrat\").SetSelected(false)\n MTD.FindByName(\"SelectGrat\").SetEnabled(false)\n break\n end\n end\n end\n if (vfl.Count = 0) then\n MsgBox.Info(\"Your ViewFrames do not reference any view documents.\",\"Cannot Create Graticule or Grid\")\n return nil\n end\n ViewFrames.DefineFromList(vfl)\n av.Run(\"GratGrids.LayoutGraticule Default Interv
SourceCode: "theLayout = av.GetActiveDoc\nif (theLayout.Is(Layout)) then\n theGraphics = theLayout.GetGraphics\n vfs = av.GetActiveDoc.GetGraphics.FindAllByClass(ViewFrame)\n vfl = {}\n Enabled = true\n if (vfs.Is(List)) then\n for each vf in vfs\n if (vf.GetFillObject <> nil) then\n vfl.Add(vf.GetFillObject.GetName)\n end\n end\n if (vfl.Count = 0)then\n Enabled = false\n end\n else\n Enabled = false\n end\nelse\n Msgbox.Info(\"Please make your layout active again.\",\"Oops\")\n return nil\nend\nS
elf.SetEnabled(Enabled)"
)
(Script.139
Name: "GratGrids.LayoutGraticule Close"
SourceCode: "if (av.GetProject.IsClosing) then\n return nil\nend\n\nMTD = av.FindDialog(\"Grat Grids Layout Grids and Graticules\")\ntheLayout = av.GetActiveDoc\nif ( Not (theLayout.is(Layout))) then\n Msgbox.Info(\"Your Graticule preview was not removed because your layout was not the active document.\",\"Oops\")\n return nil\nend\ntheGraphics = theLayout.GetGraphics\ntests = theGraphics.FindAllByName(\"Preview_GratGrid\")\nif (tests <> nil) then\n for each gsgx in tests\n theGraphics.RemoveGraphic(gsgx)\n end\nend\n"
)
(Script.140
Name: "GratGrids.LayoutGraticule Update Panels"
SourceCode: "MTD = av.FindDialog(\"Grat Grids Layout Grids and Graticules\")\ntheLayout = av.GetActiveDoc\nif ( Not (theLayout.is(Layout))) then\n Msgbox.Info(\"Please make your layout active again.\",\"Oops\")\n return nil\nend\n\nCancelButton = MTD.FindByName(\"Cancel\")\nBackButton = MTD.FindByName(\"Back\")\nNextButton = MTD.FindByName(\"Next\")\nFinishButton = MTD.FindByName(\"Finish\")\nOptionPanel = MTD.FindByName(\"OptionPanel\")\nGratPanel = MTD.FindByName(\"GratOptions\")\nGridPanel = MTD.FindByName(\"gridpanel\")\nBorderPanel = MTD.FindBy
hics = theLayout.GetGraphics\nif (self.Getname = \"Cancel\") then\n tests = theGraphics.FindAllByName(\"Preview_GratGrid\")\n if (tests <> nil) then\n for each gsgx in tests\n theGraphics.RemoveGraphic(gsgx)\n end\n end\n MTD.Close\n return nil\nend\n\n\nif (((Self.GetName = \"Next\") and (Self.GetLabel = \"Remove\")) or ((Self.GetName = \"Cancel\") and (NextButton.GetLabel = \"Remove\")))then\n NextButton.SetLabel(\"Next >>\")\n NextButton.SetHelp(\"Shows the next panel of the graticule and grid wizard\")\n tg = av.Get
ActiveDoc.GetGraphics.FindAllByName(\"Preview_GratGrid\")\n if (tg <> nil) then 'cos somebody might hit delete\n for each gsgx in tg\n theGraphics.RemoveGraphic(gsgx)\n end\n if (Self.GetName = \"Cancel\") then\n MTD.Close\n end\n end\n FinishButton.SetLabel(\"Preview\")\n FinishButton.SetHelp(\"Previews the graticule or grid using the current settings\")\n if (BorderPanel.IsEnabled) then\n NextButton.SetEnabled(false)\n BackButton.SetEnabled(true)\n else\n NextButton.SetEnabled(true)\n if (
OptionPanel.IsEnabled) then\n BackButton.SetEnabled(false)\n else\n BackButton.SetEnabled(true)\n end\n end\n return nil\nend\n\nif (av.GetActiveDoc.Is(Layout)) then\n if (OptionPanel.IsEnabled) then\n vfrN = MTD.FindByName(\"viewFrames\").GetSelection\n theVfs = theLayout.GetGraphics.FindAllByClass(ViewFrame)\n for each vf in theVfs\n theView = vf.GetFillObject\n if (theView = nil) then\n continue\n end\n vfrN = vf.GetFillObject.GetName\n vN = vf\n end\n av.Run(\"G